package _2FindAlgorithm.src.BinarySearch;

import java.util.Arrays;

public class Demo2_BinarySearch_Java {
    public Demo2_BinarySearch_Java() {
    }

    public static void main(String[] args) {
        int[] s = new int[]{1, 2, 6, 7, 9};
        int target = 3;
        int i = Arrays.binarySearch(s, target);
        System.out.println(i);
        int[] sq = new int[s.length + 1];
        System.arraycopy(s, 0, sq, 0, Math.abs(i + 1));
        sq[Math.abs(i + 1)] = target;
        System.arraycopy(s, Math.abs(i + 1), sq, Math.abs(i + 1) + 1, s.length - Math.abs(i + 1));
        System.out.println(Arrays.toString(sq));
    }
}